package exam.bak.tencent;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

public class P3 {
    static Map<Character, Integer> priMap = new HashMap<>();

    public static void main(String[] args) {
        priMap.put('@', 3);
        priMap.put('x', 2);
        priMap.put('+', 1);
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine().trim();
        Stack<Long> numStack = new Stack<>();
        Stack<Character> optStack = new Stack<>();
        for (int i = 0; i < str.length(); ) {
            char c = str.charAt(i);
            if ('0' <= c && c <= '9') {//数字
                //录入数字
                StringBuilder sb = new StringBuilder();
                while ('0' <= c && c <= '9') {
                    sb.append(c);
                    if (++i >= str.length()) {
                        break;
                    }
                    c = str.charAt(i);
                }
                //转整数
                numStack.push(Long.parseLong(sb.toString()));
            } else if (c == '@') {
                if (optStack.isEmpty() || !checkPri(optStack.peek(), c)) {
                    optStack.push('@');
                } else {//优先级大进行计算
                    numStack.push(compute(optStack.pop(), numStack.pop(), numStack.pop()));
                    continue;
                }
                i++;
            } else if (c == 'x') {
                if (optStack.isEmpty() || !checkPri(optStack.peek(), c)) {
                    optStack.push('x');
                } else {//优先级大进行计算
                    numStack.push(compute(optStack.pop(), numStack.pop(), numStack.pop()));
                    continue;
                }
                i++;
            } else if (c == '+') {
                if (optStack.isEmpty() || !checkPri(optStack.peek(), c)) {
                    optStack.push('+');
                } else {//优先级大进行计算
                    numStack.push(compute(optStack.pop(), numStack.pop(), numStack.pop()));
                    continue;
                }
                i++;
            }
        }
        while (!optStack.isEmpty()){
            numStack.push(compute(optStack.pop(), numStack.pop(), numStack.pop()));
        }
        System.out.println(numStack.pop());
    }

    private static boolean checkPri(char opt1, char opt2) {
        return priMap.get(opt1) >= priMap.get(opt2);
    }

    private static long compute(char opt, long a, long b) {
        if (opt == '@') {
            return a | (a + b);
        } else if (opt == 'x') {
            return a * b;
        } else {
            return a + b;
        }
    }
}
